<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="${pageContext.request.contextPath}static/js/jquery-3.6.0.js"></script>
    <title>登录</title>
</head>
<body>

<p id="p"></p>用户名:<input type="text" id="name" onblur="examine()">


<script>
    function examine() {
        $.post("${pageContext.request.contextPath}/a3", {name: $("#name").val()}, function (data) {
            var msg;
            if (data) {
                msg = "OK";
                $("#p").style = "color:green";
            } else {
                msg = "用户名已存在";
                $("#p").style = "color:red"
            }
            $("#p").html(msg);
        })
    }
</script>

</body>
</html>
